Performance evaluation of PSO-PID and PSO-FLC for continuum robot’s developed modeling and control

Continuum robots are complex structures that require sophisticated modeling and control methods to achieve accurate position and motion tracking along desired trajectories. They are highly coupled, nonlinear systems with multiple degrees of freedom that pose a significant challenge for conventional approaches. In this paper, we propose a system dynamic model based on the Euler–Lagrange formulation with the assumption of piecewise constant curvature (PCC), where we accounts for the elasticity and gravity effects of the continuum robot. We also develop and apply a particle swarm optimization (PSO) algorithm to optimize the parameters of our developed controllers: an inverse dynamic proportional integral derivative (PID) controller and an inverse dynamic fuzzy logic controller (FLC), where we use the integral time of absolute error (ITAE) as the objective function for the PSO algorithm. We validate our proposed model and optimized controllers through different designed trajectories, simulated using our developed unique animated MATLAB simulation. The results show that the PSO-PID controller improves the rise time, overshoot percentage, and settling time by 16.3%, 31.1%, and 64.9%, respectively, compared to the PID controller without PSO. The PSO-FLC controller shows the best performance among all controllers, with a settling time of 0.7 s and a rise time of 0.4 s, leading to the highest level of precision in trajectory tracking. The ITAE error for the PSO-FLC controller is 11.4% and 29.9% lower than that of the PSO-PID and FLC controllers, respectively.

www.nature.com/scientificreports/have been developed and applied successfully to different tasks, such as workspace analysis, trajectory tracking and whole-arm manipulation.
Finite element techniques 17 and the Cosserat rod theory 18 are excellent tools for describing system dynamics.Till et al. 19 present a real-time simulation framework for soft and continuum robots based on Cosserat rod models.They derive the equations of motion using the principle of virtual work and discretize them using finite differences.F. Janabi-Sharifi 20 provide a tutorial on Cosserat rod-based dynamic modeling of tendon-driven continuum robots.They review the basics of Cosserat rod theory and its application to continuum robots.It can be inferred that Cosserat rod theory provides a low-cost and flexible modeling approach for soft and continuum robots, which exhibit large shape deformations and environmental adaptability.However, this approach also faces some challenges, such as the need to simplify and approximate the robots' physical properties and performance.It also requires precise knowledge of the material parameters and initial conditions, which may be difficult to obtain or estimate in practice.
Due to coupled, computationally costly formulae controlling the dynamics, the real-time application has only been feasible for simpler robots with a limited number of degrees of freedom.Therefore, it is difficult to use them in the construction of real-time dynamic controllers.The design of nonlinear resilient adaptive controllers is additionally challenging due to the structure of their dynamic equations.
In contrast, the Euler-Lagrange approach 21,22 , based on piecewise constant curvature assumption (PCC), uses system developed potential, and kinetic energy in developing the CR equation of motion.Where it considers system elasticity and gravity effect.Providing suitable inverse dynamics needed for model-based controller design or path planning.
Particle swarm optimization (PSO) is a popular meta-heuristic algorithm inspired by the collective behavior of social swarms in nature.It has been widely applied to various optimization problems in different domains, such as engineering, science, and business.However, PSO also faces some challenges, such as premature convergence, stagnation, and parameter tuning.To overcome these limitations, many variants, and modifications of PSO have been proposed 23 .
Again it is an extensive and time-consuming task to develop a reliable, efficient control algorithm for controlling the position and movement of soft continuum robotic manipulator along a desired trajectory.
Therefore, by proposing a two section CR dynamics model presented leveraging the Eular-Lagrange representation founded on the PCC assumption, we develop and apply two different control algorithms based on the utilized system inverse dynamics to handle system coupling and nonlinearity, (a) inverse dynamic PID controller.(b) inverse dynamics FLC.By this point, particle swarm optimization (PSO) was used as a tuning/optimization method developed and applied for both the PID and the FLC, where the PSO was used to optimize the parameter constants K p , K i and K d of the developed PID, while for the developed FLC, the PSO was used to tune the membership function range for each input and output.
By the end, various dynamic control system outputs to a desired space parameter values were simulated and evaluated using MATLAB Simulink through designed trajectories (a) infinity shape.(b) rectangular path.Where the exported data is used in construction of a distinctive graphical interactively moving simulation.
The following points highlight the original contributions of this work: • We proposed a two-section CR developed dynamic model using Eular-Lagrange representation founded on the assumption of the PCC, which accounts for its elasticity and gravity effect solved using a MATLAB symbolic toolbox.• We Proposed two different control algorithms, inverse dynamic PID and inverse dynamic FLC that are care- fully developed and implemented for accurate position trajectory tracking control, as they are further well optimized using developed multiple iteration PSO.• The proposed PSO-optimized controllers are verified through the designed trajectory using MATLAB Sim- ulink, where a comparative analysis is conducted to demonstrate the multiple dynamic responses and optimization enhancements for each designed controller in mapped two-dimensional trajectories, demonstrated using created unique animated simulation.
The rest of this work is structured as follows: Sect."Kinematics modeling" introduces the robot's mechanical structure and the kinematic model of the two-sections CR based on the PCC assumption, proceeded by the formulation of the dynamic model utilizing classical Euler-Lagrange representation, which is demonstrated in Sect."Dynamics modeling".PSO-based optimization of two control strategies and their development and analysis are discussed in Sect."Controller design and optimization".Section "Simulation and results" details the responses of the step and trajectory tracking, and how they are simulated with MATLAB and Simulink.At last, Sect."Conclusion" concludes the paper and outlines further research plans.

Kinematics modeling
The CR structure, demonstrated in Fig. 1 comprises a flexible backbone, three driving wires, and an array of disks.Each section core comprised of a long flexible backbone and five fixed disks that are evenly spaced.The disks have three circular holes that are 120° apart for the driving wires.The driving wires can exert a moment on the tip of the flexible backbone to manipulate the CR's behavior.The CR's spatial mobility hinges on the deflection of the flexible backbone, which is attained by applying suitable tension forces to one or two wires at a time.The CR undergoes a two-DOF bending motion, that can be utilized to construct a multi-degree of freedom continuum manipulator by utilizing multiple two degree of freedom links.
The continuum robot's modelling process begins with the development of a system kinematic model.Here, we first adopt the PCC assumption, which represents the configuration space of the CR as a limited number of mutually tangent curved segments, each of which has a constant curvature over its length.
The bending of each part of the CR is regarded as an arc based on the PCC assumption of modelling CRs given in Refs. 9,24.Figure 2 shows the curvature parameters where, θ i the angle that each section's bending is represented by, ϕ i the arc plane corresponding angle, l i each section's arc length, r i radius of curvature, β i the tangent bending curve angle of the PB, s i the subsection's arc length.Where i represents section number.

Forward kinematics
Each ith section's transformation matrix in regard to the [frame i − 1 ] expressed by T i−1 i ∈ R 4×4 as follows 9,25 : (1) θ s i = s i θ i /l i .The subsequent matrix denotes the final location of each subsection relative to the [frame i − 1 ], given The position of each section's end relative to [frame 0], 0 0 1 and 0 0 2 are obtained by substituting i = 1, 2 and s 1 = l 1 , l 2 , respectively.Where the position of subsection in second section O 0 s 2 expressed as: where the second section end position (end effector) with regard to [Frame 0] 0 0 2 are obtained by simply substituting s 2 = l 2 in (4).

Inverse kinematics
Given the terminal locations of each segment relative to [frame 0] depicted in Fig. 2, the configuration angles [θ 1 ϕ 1 β 1 θ 2 ϕ 2 β 2 ] of the two-sections CR can be derived geometrically as follows 9 :

Dynamics modeling
As demonstrated in Fig. 1, continuum robot consists of segments, each of which comprises of a primary backbone (PB), parallel secondary backbones (SBs) distributed 120 degrees apart, and multiple discs.
This section presents dynamic model of a two-section CR using Eular-Lagrange representation, through which kinetic and detailed-potential energy of each subsection are presented.In addition, symbolic-math toolbox of (MATLAB) was used to solve system partial differential equation.

Kinetic energy derivation
Kinetic energy is consisting of three component of the three parts PB, SBs, and discs for each section.Firstly, the kinetic energy component belonging to the PBs denoted by KE Pb attainable as follows: where, ρ P denotes the density, A P represents cross-section area, and I P signifies the PB second moment of cross- sectional area.
The following method is used to determine the SB lengths: where, α is the gap between the primary backbone and each secondary backbone.
The system kinetic energy of the SBs is the second component, it is separated into two parts.By replacing each 1 2 with 3 2 and each subscript "P" insisted of "S" in (8), The first component KE Sb 1 can be computed.The second component can be built as follows by differentiating the actuators' lengths: (2) ( (5) where, m S is the mass of each SB.
The third component of the kinetic energy, is the discs kinetic energy KE D , which can be obtained by deriv- ing the velocity of each disc.By substituting Where KE D can be articulated by: The letters n 1 and n 2 denote the disc count in the initial and subsequent segments of the CR, respectively.Where h represents the space between each disc.and k i = 1, 2, 3, . . ., n i .The symbols m D and I D represent every disk mass and the mass moment of inertia.

Potential energy derivation
The CR has two types of potential energy: the potential energy due to gravity and elasticity.These are derived from both the PB and the discs.
Given that the orientation of the positive x 0 − axis coincides with the gravitational acceleration (g).The formula for the gravitational potential energy component of the PB (GPE Pb ) is given by: The total gravitational potential energy of the two-sections continuum robot GPE D denoted as following: The elastic potential energy is provided by: where, E P and E S denotes PB and SBs elasticity modules, respectively.
By summing all the potential energy components ( 13), ( 14) and ( 15) system potential energy (PE) can be obtained.
The equation of motion can be expressed in its final form as follows: where, M q presents the inertia matrix of dimension 4 × 4 , V q is the 4 × 4 matrix that contains the centrifugal Coriolis torque components , G q is the 4-dimensional vector that represents the gravitational torques while τ is the 4-dimensional vector of the CR torques.

Controller design and optimization
Controlling continuum robot arms poses significant challenges due to their highly nonlinear and coupled dynamics.In this section, we aim to develop and apply two different controllers whose parameters are optimized using particle swarm optimization.There are inverse dynamic PID and inverse dynamic FLC.
The system configuration space error e(t) ∈ R 4 (error vector), defined as: 3 2 ( M q q + V q, q q + G q = τ , where the desire configuration space angle denoted as q T , which, in the instance of trajectory tracing, could be a time function.

PSO optimized PID controller
The objective is to ensure that the CR time parameters coordinates q(t) converge to a desired time profile defined by the vector qd(t), such that the error e(t) = qd(t) − q(t) vanishes asymptotically.A second-order error equation is required for this purpose.A linear form of the error equation can be selected as follows: The coordinate vector q's second-order time derivative can be obtained from (20) as: The purpose of our controller is to choose a suitable control input U(t) ∈ R 4 to converge the tracking error e(t) to zero.We derive the following inverse dynamic control law: The resulting control law is obtained by inserting Eq. ( 21) into the system dynamic model ( 18): where K p , K i and K d are the proportional, integral constant control gains, respectively.qd ∈ R 4 is the second derivative value of the desired trajectory.By choosing a set of appropriate gain values of K p , K i and K d the con- figuration variables of the close-loop system is able to track the desired trajectory and minimize the error e(t).
PSO algorithm is a swarm-based search method that operates on a D-dimensional solution space.Each potential solution is represented by a particle that has a position and a velocity and can store the best position of itself and the swarm.At each iteration, the particles update their velocities and positions based on the information of their best positions.The particles dynamically explore the solution space until they converge to an optimal or near optimal state or exceed the computational budget.The objective functions provide the linkage among different dimensions of the problem space.Figure 3 demonstrate our PSO algorithm flowchart.
Particle swarm optimization (PSO) method was used for optimal tuning of the PID controller parameter constants ( K p , K i and K d ).As Fig. 4 presents the particle's initial search values for the full swarm, while Fig. 5 demonstrates the full swarm initial values distribution in three-dimensional space, where each plot represents a single ( K p , K i and K d ) value with respect to the search space.
Where Each particle movement of the PSO is influenced by its own best known position and the best known positions of other particles, where the velocity equation: where v t i symbolizes the inertia, c 1 and c 2 are the positive acceleration constants of cognitive and social com- ponents, respectively, r 1 and r 2 are random numbers, P best is the personal best position, G best is the global best position and P t i is the position vector of particle i at time t.A particle's velocity depends on how much it trusts itself c 1 and its neighbors c 2 , as well as some random fac- tors ( r 1 and r 2 ).These are the acceleration coefficients that affect the cognitive and social aspects of the particle.If c 1 and c 2 are both zero, particles keep flying at the same speed.If only one of them is positive, particles either do a local search c 1 or follow the best position in the swarm c 2 .The best performance is achieved when c 1 and c 2 are balanced and close to each other, i.e. c 1 ≈ c 2 .This way, particles are influenced by both their own and their neighbors' best positions.
The position equation of each particle in the swarm given by: The cost function is selected to be the time integral of absolute error (ITAE): which is a performance index that is used to evaluate the performance of a system.The ITAE cost function is designed to penalize large errors more than small errors by using the absolute value.It also penalizes errors that persist for a long time more than errors that are transient by using the time factor.The ITAE cost function gives more weight to the settling time than the rise time or overshoot of the response.

PSO optimized FLC controller
An artificial intelligence-based control approach, FLC utilizes the system's prior knowledge to formulate decision rules.The functionary's main task is to determine the linguistic variables and the rules based on the system's ( 19) e(t) = q (d) (t) − q(t) = e (θ1) e (ϕ1) e (θ2) e (ϕ2) M q qd + K p e + K i e dt + K d ė + V q, q q + G q = t PID .behavior and the controlled system's context.The proposed FLC controller, combined with the inverse dynamic model of the system, mitigates the effects of system coupling and nonlinearity.
Particle swarm optimization (PSO) was used for tuning controller parameters.Where FLC rules were designed based on a thorough knowledge of system dynamics, ranges of inputs and outputs were initialized using trial and error, then the PSO was used to tune the ranges of all membership's functions for each input and output.
The error ( e ) and its derivative ( ė ) of both ( θ i ) and ( ϕ i ) are used as inputs of the FLC.Where the linguistic variables for inputs and outputs are expressed as follow: The inputs variables expressed as; Negative big (NB) Negative medium (NM) Zero (Z) Positive medium(PM) Positive big(PB) , and

Reducing big(RB) Reducing medium(RM) Medium(M) Growing Medium(GM)
Growing big(GB) The output variable expressed as: where Table 1 present the rule base table for the FLC, where first input are ( e θ i , e ϕ i ) and the second input are ( ėθ i , ėϕ i ), as previously explained.
(26) τ (fuzzy) = M q q(fuzzy) + V q, q q + G q ,  The range of each membership function are tuned using particle swarm optimization (PSO), while ( 21) and ( 22) used to update particles velocity and location respectively, where each particle represents different change to the range of the membership function.Which results in a different ITAE value (23).
Figure 6 presents the PSO-FLC input's and output's membership function, produced by the last iteration of the PSO with the least ITAE value, while demonstrating its shapes and tuning for every membership range.While Fig. 7 demonstrate the PSO-FLC control surface, for e (θ ,ϕ) , ė(θ,ϕ) as inputs, and ( θ, φ) as outputs, Now we can see that by choosing the identical membership function ranges for both the input and output, Fig. 7a and b are quite comparable to one another.
The developed particle swarm optimization algorithm is illustrated by the following pseudocode, which shows the main steps of the algorithm and the formulas used to update the position and velocity of each particle.The online resource (Supplementary Video 1) provides a detailed analysis of how the PSO algorithm improves the performance of both the PID and FLC controllers.It shows how the controller responses change with each iteration of the PSO algorithm and how they converge to optimal values.

Simulation and results
In this section, MATLAB Simulink, with the aid of the system dynamic model, is used to simulate the CR arm response for the proposed controllers PSO-PID and PSO-FLC for both given step inputs and desired trajectories.Table 2 lists the continuum manipulator's material and geometric characteristics.
The system configuration space initial value of q = [0.001• 0 • 0.001 • 0 • ] T was precisely selected after a thor- ough analysis of the CR workspace and its dynamics to prevent singularities.We perform the simulation based on the PID and FLC parameters determined by the particle swarm optimization (PSO).In the case of the PID controller, the parameters gain constant K p , K i and K d are 40, 0.1 and 6.72 respectively, while Fig. 6 shows the FLC membership functions, shapes, and ranges.
The PSO parameters are set to be c 1 = c 2 = 2 , while r 1 , and r 2 are random numbers generated online through model simulation and iteration progress.The initial population values are presented in Fig. 4, with swarm size (Np = 40), and iterations number (n = 10).

Step response
To assess the reliability and effectiveness of each controller, the optimized control algorithms are examined using MATLAB to simulate system response to a given different step inputs, where the desired configuration space angels are q = [80 • 90 • 110 • 180 • ] T at time t = 0sec and changed its desired configuration at time t = 4sec to q = [40    For the case of the FLC, the PSO optimization develops more suitable ranges for the inputs and outputs membership function, as demonstrated in Fig. 6, while Fig. 9 shows how the PSO FLC line closely follows the desired line, indicating that the PSO has effectively optimized the FLC membership function, resulting in a more accurate and responsive control of the robot's movement.On the other hand, the trial-and-error FLC line shows more deviation from the desired line, suggesting less precision and slower response times.
The full dynamic response of the optimized controller is demonstrated by Fig. 10, which shows the great responsiveness of the controller (error and change of error) at the aggressive change of the desired values at sharp step input.
Figure 11 shows a response comparison between PSO-PID and PSO-FLC for each configuration space parameters [θ 1 ϕ 1 θ 2 ϕ 2 ] , where it shows the overcoming of FLC over the PID in terms of overshoot and settling time, although the PID experiences a lower rising time.This comparison clearly illustrates the significant enhancement in the continuum robot's dynamic response when using PSO for optimizing the FLC membership function.The robot is able to achieve the desired angles more accurately and quickly, improving its overall performance and efficiency.This is particularly important in applications where precise and rapid movement is required.Figure 12 compares the Integral Time Absolute Error (ITAE) performance index of a Fuzzy Logic Controller (FLC) and a Proportional-Integral-Derivative (PID) controller over a series of iterations.The ITAE is a measure of the controller's performance, with lower values indicating better performance.The red line represents the FLC's ITAE, while the blue line represents the PID's ITAE.From the graph, it's clear that the FLC outperforms the PID controller in terms of ITAE.The FLC's ITAE starts at around 15 and decreases to around 13 over 10 iterations, indicating an improvement in performance.On the other hand, the PID's ITAE starts at a much higher value of around 44 and only decreases to around 32 over the same number of iterations.

Trajectory tracking response
This section covers the optimized controller's dynamic behavior to a certain trajectory.Two simulation scenarios have been run up to this point in a two dimensional plane, infinity shape and rectangular trajectories.
Firstly, the infinity shape trajectory, centered at the point (0.5, 0.5) within the plane of [x-z], where the curvature plane ϕ 1 = ϕ 2 = 0 .Figure 13a presents trajectory tracking of both controller PID and FLC, while Fig. 13b presents a magnified response of the trajectories, The results show that the PSO-PID and PSO-FLC controllers are able to track the infinity path with high accuracy and low error.The PSO-PID controller has a faster response time and a smaller settling time than the PSO-FLC controller, as shown in panel (b).However, the PSO-FLC controller has a smoother response and no overshoot, unlike the PSO-PID controller, which has some oscillations and overshoot around the desired trajectory.Therefore, the PSO-FLC controller is more suitable for applications  that require smooth and precise tracking, while the PSO-PID controller is more suitable for applications that require fast and robust tracking.
Figure 14 provides a comparative analysis of the response of configuration space variables [θ 1 θ 2 ] to the desired trajectory [θ 1d θ 2d ] for an infinity path, as controlled by both a PSO-FLC and a PSO-PID controller.
The dynamic response depicted in the figure indicates that the FLC controller exhibits superior accuracy in tracking the desired angle compared to the PID controller.This is further evidenced by the reduced overshoot and oscillation demonstrated by the FLC controller, implying a lesser degree of deviation or exceedance from the desired angle.
Moreover, the FLC controller's adaptability to nonlinear and complex behavior outperforms that of the PID controller.This adaptability is particularly crucial in managing systems with intricate dynamics, thereby underscoring the effectiveness of FLC controllers in such scenarios.
Secondly, the rectangular trajectory with starting corner at point (0.65, 0.6) within the same [x-z] plane.Figure 15a presents the controller dynamic response tracing trajectory.While Fig. 15b presents a magnified view of the response showing PSO-PID tracking error owing to its noticeable overshoot, causing a portion of error at starting point of every rectangular side.As it demonstrates the effectiveness of the PSO-FLC in tracking aggressively changing trajectories, with orthogonal angles as the rectangular path.
Figure 16 demonstrates the dynamic repones for each configuration space parameter.The results show that both control methods can make the robot follow the rectangular path with reasonable accuracy, but FLC has some advantages over PID.In panel (a), FLC has less overshot and settling time than PID, meaning that it can reach the desired angle faster and with less oscillation.In panel (b), FLC has less steady-state error than PID, meaning that it can maintain the desired angle more precisely.
The proposed controllers are validated by comparing their performance with two existing controllers from the literature Fig. 17: a FLC by (Osama et al. 25 ) and a PID by (Amori et al. 21).The graphs show the angular responses of the two links.The enhancement percentage of the controllers relative to each paper is calculated as follows: • The PSO-FLC controller achieved an enhancement of 14.29% over the FLC by (Osama et al. 25 ), as it reduced the steady-state error from 0.7 degrees to 0.6 degrees.• The PSO-PID controller achieved an enhancement of 16.67% over the PID by (Osama et al. 25 ), as it reduced the overshoot from 6 to 5 degrees.• The PSO-PID controller achieved an enhancement of 20% over the PID by (Amori et al. 21), as it reduced the settling time from 10 to 8 s.  25 ) and (Amori et al. 21) response.

Figure 1 .
Figure 1.Design element for a two-section continuum robot.

Figure 2 .
Figure 2. Parameters diagram for the two-section continuum robot.

Figure 5 .
Figure 5. Particles initial distribution in search space for the PID parameters.

Figure 6 .
Figure 6.PSO membership functions for inputs and outputs of FLC.

Figure 8 .
Figure 8. Enhanced response of PSO verses trial and error PID.

Figure 9 .
Figure 9. Enhanced response of PSO verses trial and error FLC.

Figure 11 .
Figure 11.PSO response for both PID and FLC.

Figure 13 .
Figure 13.Trajectory tracking performance of PSO-PID and PSO-FLC for infinity path (a) trajectory full response (b) magnified response.

Figure 15 .
Figure 15.Trajectory tracking performance of PSO-PID and PSO-FLC for rectangular path (a) trajectory full response (b) magnified response.

Figure 17 .
Figure 17.Compare current work proposed controller response to literature work (Osama et al.25 ) and (Amori et al.21 ) response.

Table 1 .
PSO-FLC rule base table, inputs, and output linguistics.(e) presents the error of θ i and ϕ i , while ė presents the error (e) time derivative.

Table 2 .
Chosen parameters of the CR.

Table 3 .
Performance comparison of system response for controllers with and without PSO optimization.

Table 3
presents a complete comparison of results between different optimized controllers, showing the enhancement in terms of rise time, settling time, and overshoot percentages.